<navigation:Page 
    x:Class="ibba.src.noriskbo.PageLancamentosManuais"     
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:ig="http://schemas.infragistics.com/xaml"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"     
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"  
    xmlns:behavior="clr-namespace:ibba.src.noriskbo.code.behavior"
    mc:Ignorable="d" 
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"    
    xmlns:local="clr-namespace:ibba.src.noriskbo"
    xmlns:slc="clr-namespace:ibba.src.sl.componentes;assembly=ibba.src.sl.componentes"
    d:DesignHeight="200" d:DesignWidth="800">

    <Grid x:Name="LayoutRoot" Margin="10,5,10,5" Background="White">
        <toolkit:BusyIndicator x:Name="busyCarregando" BusyContent="Carregando...">
            <Grid Name="gridConteudo">
                <Grid.RowDefinitions>
                    <RowDefinition Height="52"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="20"/>
                </Grid.RowDefinitions>

                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    
                    <Border Grid.Column="0" Margin="0,0,3,3" Padding="3" CornerRadius="6" BorderBrush="Silver" BorderThickness="1" Background="#29C0C0C0" >
                        <Image Name="imgIconeTela" Source="{StaticResource BotaoValidarArq}" />
                    </Border>
                    
                    <StackPanel VerticalAlignment="Top" Grid.Column="1">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom">
                            <Grid Name="gridTabOperacoes" VerticalAlignment="Bottom">
                                <sdk:Label Name="tabOperacoes" Style="{StaticResource TabAtiva}" Content="Operacoes   " Margin="0,0,0,0" MouseLeftButtonUp="tabOperacoes_MouseLeftButtonUp" />
                                <sdk:Label Name="lblOperacoesSelecionadas" Content="0" Style="{StaticResource LegendBlue}" 
                                           HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,2,2,0" Visibility="Visible" />
                            </Grid>
                            <Grid Name="gridTabGarantias" VerticalAlignment="Bottom">
                                <sdk:Label Name="tabGarantias" Style="{StaticResource TabInativa}" Content="Garantias   " MouseLeftButtonUp="tabGarantias_MouseLeftButtonUp"/>
                                <sdk:Label Name="lblGarantiasSelecionadas" Content="0" Style="{StaticResource LegendGray}" 
                                           HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,2,2,0" Visibility="Visible" />
                            </Grid>
                        </StackPanel>

                        <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left"/>

                        <StackPanel x:Name="panelCheckbox" Orientation="Horizontal" Margin="3">
                            <CheckBox Name="chkSelecionarRegistros" Content="Selecionar todos"                                       
                                      HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                                      Margin="3,0,0,0"
                                      Click="chkSelecionarRegistros_Click"/>

                            <CheckBox x:Name="chkSelecionarGarantiasDaOperacao" Content="Auto selecionar garantias da operação" Foreground="OrangeRed" 
                                  HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                                  IsChecked="True" Margin="8,0,0,0" 
                                  Visibility="{Binding Visibility, ElementName=xgOperacoes}" 
                                  Click="chkSelecionarGarantiasDaOperacao_Click"/>
                        </StackPanel>
                    </StackPanel>
                    
                


                    <Border Style="{StaticResource borderOpcaoFiltro}"  CornerRadius="6,6,0,0" Margin="0,0,0,-2"
                            HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.ColumnSpan="2" >

                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Height="16" Margin="2,0,3,0">
                            <TextBlock Text="Filtro: " HorizontalAlignment="Left" Style="{StaticResource SubTitleHeader}" FontSize="11" Height="16"/>
                            <Image Source="{StaticResource IconeFiltro}" Height="16" Width="16" />

                            <StackPanel x:Name="panelFiltroStatus" Orientation="Horizontal">
                                <CheckBox x:Name="chkFilterStatusEA" Content="Em Aprovação" IsChecked="True" Margin="12,0,0,0" Click="chkFiltroStatus_Click" />
                                <CheckBox x:Name="chkFilterStatusEE" Content="Em Exclusão" IsChecked="True" Margin="12,0,0,0" Click="chkFiltroStatus_Click" />
                                <TextBlock Text="|" Style="{StaticResource SubTitleHeader}" FontSize="12" VerticalAlignment="Top" Margin="12,0,0,0"/>
                            </StackPanel>
                            <StackPanel x:Name="panelFiltroVencimento" Orientation="Horizontal" Visibility="Collapsed">
                                <CheckBox x:Name="chkFilterVencidas" Content="Vencidas" IsChecked="True" Margin="12,0,0,0" Click="chkFiltroStatus_Click" />
                                <CheckBox x:Name="chkFilterAVencer" Content="Á vencer" IsChecked="True" Margin="12,0,0,0" Click="chkFiltroStatus_Click" />
                                <TextBlock Text="|" Style="{StaticResource SubTitleHeader}" FontSize="12" VerticalAlignment="Top" Margin="12,0,0,0"/>
                            </StackPanel>
                            <CheckBox x:Name="chkFiltroUsuario" Content="Minhas solicitações" IsChecked="False" Margin="10,0,0,0" Click="chkFiltroUsuario_Click" />
                        </StackPanel>

                    </Border>

                </Grid>

                <ig:XamGrid Name="xgOperacoes" Grid.Row="1" VerticalAlignment="Top"
                            GroupByCollectionChanged="xgOperacoes_GroupByCollectionChanged"
                            Margin="0,0,0,31">

                    <i:Interaction.Behaviors>
                        <behavior:XamGridBehavior x:Name="xgOperacoesBehavior" IsExpandRowGrouped="True" />
                    </i:Interaction.Behaviors>

                    <ig:XamGrid.Columns>
                        <ig:TemplateColumn x:Name="colSelecionado" Key="Selecionado" HeaderText=" " Tag="True" Width="30" IsFilterable="False" IsGroupable="False" IsResizable="False" IsHideable="False">
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Name="chkSelecionarRegistro" 
                                              HorizontalAlignment="Center" VerticalAlignment="Center"
                                              IsChecked="{Binding Mode=TwoWay, Path=Selecionado}"
                                              Click="chkSelecionarRegistro_Click" 
                                              IsEnabled="{Binding IsSelectable}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        <ig:UnboundColumn Key="btnDetalhe" HeaderText=" " Width="30" IsFilterable="False" IsGroupable="False">
                            <ig:UnboundColumn.ItemTemplate>
                                <DataTemplate>
                                    <Button x:Name="btnDetalhe" Click="btnDetalhe_Click">
                                        <Image Source="{StaticResource IconeVerDetalhes}" Width="16" Height="16"/>
                                    </Button>
                                </DataTemplate>
                            </ig:UnboundColumn.ItemTemplate>
                        </ig:UnboundColumn>

                        <ig:TextColumn Key="Id" HeaderText="Id" Visibility="Collapsed"/>

                        <ig:TemplateColumn HeaderText="Status" Key="CodigoStatus" MinimumWidth="120" HorizontalContentAlignment="Left">
                            <ig:TemplateColumn.FilterEditorTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.FilterEditorTemplate>

                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="{Binding CodigoStatus, Converter={StaticResource StatusImageConverter}}" Width="16" Height="16" Margin="5,0,0,0"/>
                                        <TextBlock Text="{Binding DescricaoStatus}" Margin="5,0,5,0" Height="16" />
                                    </StackPanel>
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        
                        <ig:TemplateColumn HeaderText="Data Solicitação" Key="DataSolicitacao" HorizontalContentAlignment="Center">
                            <ig:TemplateColumn.FilterEditorTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.FilterEditorTemplate>
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding DataSolicitacao, Converter={StaticResource DateTimeConverter}, ConverterParameter='exibirHoje'}"
                                               Foreground="{Binding DataSolicitacao, Converter={StaticResource DateTimeConverter}, ConverterParameter='destaqueHoje'}" 
                                               VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        <ig:TextColumn HeaderText="Grupo" Key="NomeGrupoCliente" MinimumWidth="150" TextWrapping="Wrap" />

                        <ig:TextColumn HeaderText="Contrato" Key="CodigoContrato" MinimumWidth="120" />
                        <ig:TextColumn HeaderText="Cliente" Key="NomeCliente" MinimumWidth="150" />
                        <ig:TextColumn HeaderText="Produto / Modalidade" Key="ProdutoModalidade" MinimumWidth="150" TextWrapping="Wrap" />
                        <ig:TemplateColumn HeaderText="Abertura" Key="DataAbertura" MinimumWidth="90" HorizontalContentAlignment="Center">
                            <ig:TemplateColumn.FilterEditorTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.FilterEditorTemplate>
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding DataAbertura, Converter={StaticResource DateTimeConverter}, ConverterParameter='exibirHoje'}"
                                               Foreground="{Binding DataAbertura, Converter={StaticResource DateTimeConverter}, ConverterParameter='destaqueHoje'}" 
                                               VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        <ig:TemplateColumn HeaderText="Data Vencimento" Key="DataVencimento" MinimumWidth="90" HorizontalContentAlignment="Center">
                            <ig:TemplateColumn.FilterEditorTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.FilterEditorTemplate>
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding DataVencimento, Converter={StaticResource DateTimeConverter}, ConverterParameter='exibirHoje'}"
                                               Foreground="{Binding DataVencimento, Converter={StaticResource DateTimeConverter}, ConverterParameter='destaqueHoje'}" 
                                               VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        
                        <ig:TextColumn HeaderText="Valor Operação" Key="ValorOperacaoMoeda" FormatString="{}{0:N2}" MinimumWidth="110" HorizontalContentAlignment="Right">                            
                            <!--ig:TextColumn.ConditionalFormatCollection>
                                <ig:LessThanConditionalFormatRule Value="1" StyleToApply="{StaticResource CellTextRedStyle}" />
                            </ig:TextColumn.ConditionalFormatCollection>-->
                        </ig:TextColumn>
                        <ig:TextColumn HeaderText="Valor Contábil" Key="ValorContabilMoeda" FormatString="{}{0:N2}" MinimumWidth="110" HorizontalContentAlignment="Right">
                            <!--<ig:TextColumn.ConditionalFormatCollection>
                                <ig:LessThanConditionalFormatRule Value="1" StyleToApply="{StaticResource CellTextRedStyle}" />
                            </ig:TextColumn.ConditionalFormatCollection>-->
                        </ig:TextColumn>

                        <ig:TextColumn HeaderText="Incluído por" Key="UsuarioIncluiu" MinimumWidth="120"/>
                        <ig:TextColumn HeaderText="Alterado por" Key="UsuarioSolicitou" MinimumWidth="120"/>
                    </ig:XamGrid.Columns>
                </ig:XamGrid>
                <local:XamGridToolBar x:Name="xgOperacoesTools" Grid.Row="1" VerticalAlignment="Bottom" Visibility="{Binding Visibility, ElementName=xgOperacoes}"/>


                <ig:XamGrid Name="xgGarantias" Grid.Row="1" VerticalAlignment="Top" Visibility="Collapsed"
                            GroupByCollectionChanged="xgGarantias_GroupByCollectionChanged"
                            Margin="0,0,0,31">

                    <i:Interaction.Behaviors>
                        <behavior:XamGridBehavior x:Name="xgGarantiasBehavior" IsExpandRowGrouped="True" />
                    </i:Interaction.Behaviors>

                    <ig:XamGrid.Columns>
                        <ig:TemplateColumn Key="Selecionado" HeaderText=" " Width="30" IsFilterable="False" IsGroupable="False" IsResizable="False" IsHideable="False">
                           <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Name="chkSelecionarRegistro" 
                                              HorizontalAlignment="Center" VerticalAlignment="Center"
                                              IsChecked="{Binding Path=Selecionado, Mode=TwoWay}"
                                              Click="chkSelecionarRegistro_Click" 
                                              IsEnabled="{Binding IsSelectable}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>

                        <ig:TextColumn Key="Id" HeaderText="Id" Visibility="Collapsed"/>

                        <ig:TemplateColumn HeaderText="Status" Key="CodigoStatus" MinimumWidth="120" HorizontalContentAlignment="Left">
                            <ig:TemplateColumn.FilterEditorTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.FilterEditorTemplate>
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="{Binding CodigoStatus, Converter={StaticResource StatusImageConverter}}" Width="16" Height="16" Margin="5,0,0,0"/>
                                        <TextBlock Text="{Binding DescricaoStatus}" Margin="5,0,5,0" Height="16" />
                                    </StackPanel>
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        
                        <ig:TemplateColumn HeaderText="Data Solicitação" Key="DataSolicitacao" HorizontalContentAlignment="Center">
                            <ig:TemplateColumn.FilterEditorTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay}"/>
                                </DataTemplate>
                            </ig:TemplateColumn.FilterEditorTemplate>
                            <ig:TemplateColumn.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding DataSolicitacao, Converter={StaticResource DateTimeConverter}, ConverterParameter='exibirHoje'}"
                                               Foreground="{Binding DataSolicitacao, Converter={StaticResource DateTimeConverter}, ConverterParameter='destaqueHoje'}" 
                                               VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </ig:TemplateColumn.ItemTemplate>
                        </ig:TemplateColumn>
                        <ig:TextColumn HeaderText="Grupo" Key="NomeGrupoCliente" MinimumWidth="150" TextWrapping="Wrap"/>
                        <ig:TextColumn Key="CodigoContrato" HeaderText="Contrato" MinimumWidth="120" />
                        <ig:TextColumn Key="Numero" HeaderText="Nro." MinimumWidth="50"/>
                        <ig:TextColumn Key="NomeCliente" HeaderText="Cliente" MinimumWidth="150"/>
                        <ig:TextColumn Key="ProdutoModalidade" HeaderText="Produto / Modalidade" MinimumWidth="150" TextWrapping="Wrap"/>
                        <ig:TextColumn Key="DescricaoInstrumento" HeaderText="Instrumento" MinimumWidth="50"/>
                        <ig:TextColumn Key="DescricaoBem" HeaderText="Bem" MinimumWidth="50"/>
                        <ig:TextColumn Key="DescricaoNatureza" HeaderText="Natureza" MinimumWidth="50"/>
                        <ig:TextColumn Key="Moeda" HeaderText="Moeda" MinimumWidth="70"/>
                        <ig:TextColumn Key="ValorAtualizadoMoeda" HeaderText="Valor atualizado" MinimumWidth="120" ValueConverter="{StaticResource DecimalConverter}" HorizontalContentAlignment="Right"/>

                        <ig:TextColumn HeaderText="Incluído por" Key="UsuarioIncluiu" MinimumWidth="120"/>
                        <ig:TextColumn HeaderText="Alterado por" Key="UsuarioSolicitou" MinimumWidth="120"/>

                        <ig:ColumnLayout Key="Garantidores" AutoGenerateColumns="False" Indentation="60"
                                         Visibility="{Binding Garantidores.Count, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <ig:ColumnLayout.Columns>
                                <ig:TextColumn Key="IdGrupo" HeaderText="Id.Grupo" MinimumWidth="80" IsReadOnly="True" />
                                <ig:TextColumn Key="NmGrupo" HeaderText="Nome Grupo" MinimumWidth="150" IsReadOnly="True" />
                                <ig:TextColumn Key="IdPessoa" HeaderText="Id.Cliente" MinimumWidth="80" IsReadOnly="True" />
                                <ig:TextColumn Key="Nome" HeaderText="Nome Cliente Garantidor" MinimumWidth="150" IsReadOnly="True" />
                                <ig:TextColumn Key="CpfCnpj" HeaderText="CPF / CNPJ" MinimumWidth="120" IsReadOnly="True" ValueConverter="{StaticResource FormatCnpjCpfConverter}" />
                                <ig:TextColumn Key="PercentualGarantidor" HeaderText="% Garantido" MinimumWidth="100" IsReadOnly="True" ValueConverter="{StaticResource DecimalConverter}" FormatString="{}{0:P2}" />
                            </ig:ColumnLayout.Columns>

                        </ig:ColumnLayout>

                    </ig:XamGrid.Columns>
                </ig:XamGrid>
                <local:XamGridToolBar x:Name="xgGarantiasTools" Grid.Row="1" VerticalAlignment="Bottom" Visibility="{Binding Visibility, ElementName=xgGarantias}"/>

                <!--<StackPanel Orientation="Horizontal" Grid.Row="2">
                    <TextBlock Text="Quantidade de registros:  " Height="16" />
                    <TextBlock Name="lblQuantidadeDeRegistros" Height="16" />
                </StackPanel>
                <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left" Grid.Row="2" Margin="0,20,0,0"/>-->
                <StackPanel Orientation="Horizontal"  VerticalAlignment="Center"  HorizontalAlignment="Right" Grid.Row="2">
                    <TextBlock Name="txtMaisAntigas" Cursor="Hand" FontSize="13" Foreground="OrangeRed" VerticalAlignment="Bottom" Margin="-5,2,0,0"
                                   Text="Clique aqui para carregar mais operações"                                    
                                   MouseLeftButtonUp="txtMaisAntigas_MouseLeftButtonUp"/>
                </StackPanel>
                
            </Grid>
        </toolkit:BusyIndicator>
    </Grid>

</navigation:Page>
